home *** CD-ROM | disk | FTP | other *** search
- /* List an Lharc file's contents */
- BOOL
- ListLharc(ULONG type,UBYTE *infile)
- {
- int ct, time, date, done;
- ULONG uncomp, comp;
- UBYTE name[200],b[200],time_str[25];
- FILE *fp;
- ULONG tfiles = 0, tcomp = 0, tuncomp = 0;
-
- fp = OpenFile(type,infile);
-
- /* Read in my bytes */
- ReadBuf (22,fp,b);
-
- /* Determine if it is an Lharc file */
- if ((strncmp(b+(sizeof (char) *2),"-l",2) != 0))
- {
- fclose (fp);
- return (WRONG_ARCHIVE);
- }
-
- /* It is an Lharc file. Is it the NEW LH5 format? */
- if ((strncmp(b+(sizeof (char) *2),"-lh5",4) == 0))
- type = LHA;
-
- /* Get file name stored in archive */
- fread(name,b[21]+2,1,fp);
- name[b[21]] = 0;
-
- /* Print out header info to standard output */
- if (type != LHA) type = LHARC;
- InitList(type,infile);
-
- done = FALSE;
- while (!done)
- {
- /* Calculate Compressed, Uncompressed, Date,Time, and print it out */
- comp = GetLong(b,10);
- uncomp = GetLong(b,14);
- date = b[18] * 256 + b[17];
- time = b [16] * 256 + b[15];
- if (MSDog (time,date,time_str) == ABORT) break;
- PrintList(name, uncomp, comp,&tfiles,&tcomp,&tuncomp,time_str);
-
- /* Read in more bytes */
- fseek(fp,comp,SEEK_CUR);
- ct = fread(b,22,1,fp);
-
- if ((strncmp(b+(sizeof (char) *2),"-l",2) != 0) || (ct < 1))
- done = TRUE;
-
- /* Read in file name again */
- fread(name,b[21]+2,1,fp);
- name[b[21]] = 0;
- }
-
- fclose (fp);
- /* Print ending stats */
- EndStats(tfiles,tcomp,tuncomp);
- return (TRUE);
- }
-